package com.briup.recognition.web.controller;

import com.briup.recognition.bean.BaseConfig;
import com.briup.recognition.service.IBaseConfigService;
import com.briup.recognition.utils.Message;
import com.briup.recognition.utils.MessageUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/baseconfig")
public class BaseConfigController {
    @Resource
    private IBaseConfigService baseConfigService;

    @GetMapping("query")
    public Message query(){
        List<BaseConfig> list = baseConfigService.query();

        return MessageUtil.success(list);
    }

    @PostMapping("saveOrUpdate")
    public Message saveOrUpdate(BaseConfig baseConfig){
        baseConfigService.saveOrUpdate(baseConfig);

        return  MessageUtil.success("更新成功");
    }

    @PostMapping("deleteById")
    public Message deleteById(long id){
        baseConfigService.deleteById(id);

        return MessageUtil.success("删除成功");
    }
}
